﻿<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
       "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<link rel="stylesheet" type="text/css" href="style.css">
<link href="tablecloth/tablecloth.css" rel="stylesheet" type="text/css" media="screen" />
<script type="text/javascript" src="tablecloth/tablecloth.js"></script>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
</head>
<body>

<?php

include("inc/joomlaInt.php");
include("inc/inc_configuration.php");

if ($jUser==0)
{
	echo "Bitte zuerst einloggen!";
}
else
{

	$matchday = $_GET["matchday"];
	$liga = $_GET["liga"];


	$lq = "SELECT * FROM $tbl_lg WHERE leagueId=$liga";
	$lqe = mysql_query($lq);


	while ($gr=mysql_fetch_object($lqe))
	{
		$gId=$gr->id;
		$gn=$gr->groupName;
		$ko = $gr->knockout;
		
		
		if ($ko==0)
		{
			$gQ="SELECT * FROM $tbl_gt WHERE groupId=$gId";
			$gQe=mysql_query($gQ);
			$gQen=mysql_num_rows($gQe);
			
			
			
			if ($gQen%2 == 0)
			{
				$mAnz = ($gQen-1)*2;
			}
			else
			{
				$mAnz = $gQen*2;
			}
			

			$sQ="SELECT * FROM $tbl_matches WHERE matchday=$matchday AND stageId=$gId";
			$sQe=mysql_query($sQ);

			

			$gruppe=$gId;
			
			include("inc/inc_pokal_tabelle.php");
			
			$count=1;
			if ($mAnz>0)
			{
				echo "<table><tr><th colspan='8'>";
				echo "<center>";
			}

			for($count = 1; $count < $mAnz+1; $count++)
			{
				echo "<a href='international_spiele_spieltag.php?matchday=$count&liga=$liga'>$count</a> ";
			}

			if ($mAnz>0)
			{
				echo "</th></center></tr>";
			}

			

			while ($row = mysql_fetch_object($sQe))
			{
				$mI=$row->id;
				$homeT=$row->homeT;
				$guestT=$row->guestT;
				$hG=$row->homeG;
				$gG=$row->guestG;
				$f=$row->free;
				
				if ($f==3)
				{
					$b="<a href='spielbericht.php?matchID=$mI&type=2'><img src='img/bericht.png' alt='Spielbericht'></a>";
				}
				else
				{
					$b="";
				}
				
				if ($hG=="")
				{
					$hG="-";
					$gG="-";
					$b="";
				}
				
				
				$tHq="SELECT name FROM $tbl_teams t WHERE t.id=$homeT";
				$tGq="SELECT name FROM $tbl_teams t WHERE t.id=$guestT";
				$tHqe = mysql_query($tHq);
				$tGqe = mysql_query($tGq);
				$tHn = mysql_fetch_object($tHqe)->name;
				$tGn = mysql_fetch_object($tGqe)->name;
				
				
				$uHSql="	SELECT u.username AS uHn, c.id AS hC, u.id AS uid FROM $tbl_combinations c, $tbl_users u
							WHERE
							(c.teamId=$homeT) AND
							(c.active=1) AND
							(c.userId=u.id)";
				$uGSql="	SELECT u.username AS uGn, c.id AS gC, u.id AS uid FROM $tbl_combinations c, $tbl_users u
							WHERE
							(c.teamId=$guestT) AND
							(c.active=1) AND
							(c.userId=u.id)";
				
				$uHq = mysql_query($uHSql);
				$uGq = mysql_query($uGSql);
				
				$uHqo=mysql_fetch_object($uHq);
				$uGqo=mysql_fetch_object($uGq);
				
				$uHn = $uHqo->uHn;
				$uGn = $uGqo->uGn;
				
				$uHi = $uHqo->uid;
				$uGi = $uGqo->uid;
				
				if ($uHn=="")
				{
					$uHn = "(-)";
				}
				else
				{
					$uHn = "<a href='profil.php?id=$uHi'>$uHn</a>";
				}
				
				if ($uGn=="")
				{
					$uGn = "(-)";
				}
				else
				{
					$uGn = "<a href='profil.php?id=$uGi'>$uGn</a>";
				}
				
				echo"<tr>	<td width='44%'><center><a href='spiele_team.php?team=$homeT&liga=$liga'>$tHn</a><br>$uHn</td>
							<td><a href='team_kader.php?team=$homeT'><img src='img/logos/",$row->homeT,".png' width='35' height='35' alt=''></a></td>
							<td width='3%'><center>$hG</center></td>
							<td width='2%'><center>:</center></td>
							<td width='3%'><center>$gG</center></td>
							<td><a href='team_kader.php?team=$guestT'><img src='img/logos/",$row->guestT,".png' width='35' height='35' alt=''></a></td>
							<td width='44%'><center><a href='spiele_team.php?team=$guestT&liga=$liga'>$tGn</a><br>$uGn</center></td>
							<td width='4%'><center>$b</center></td>
					</tr>";
			}

			echo "<tr><th colspan='8'></th></tr></table><br><br>";
		}
	}
	
	echo "<center><a href='lima.php' class='button zurueck'>Zurück</a></center>";
}



?>

</body>
</html>